<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>

<html>
<head>
<meta charset="utf-8">
<title>注冊</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/statics/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/statics/css/default.css" />
<script src="${pageContext.request.contextPath}/statics/js/jquery.min.js" type="text/javascript"
	charset=utf-8></script>
<script src="${pageContext.request.contextPath}/statics/js/bootstrap.min.js" type="text/javascript"
	charset=utf-8></script>
<script type="text/javascript">
$(function() {
	$('#register-username').blur(function() {
		//alert("dss")
			 $.ajax({
				type : "get",
				url : "getUserName.action",
				data : "registerUsername=" + $('#register-username').val(),
				success : function(data) {
					var result = eval("("+data+")");
					//表示查到用户了，已经存在
					if(result != null){
						$('#msg').text("用户已经存在").css("color","red")
					}else{
						$('#msg').text("该用户可以注册").css("color","green")
					}
				}
			
			}); 
	})
})
	
	function checkForm() {
	var username = $('#register-username').val()
	var password = $('#register-password').val()
	var passwords = $('#register-passwords').val()
	
	if(username == "" || password == "" || passwords == ""){
		alert("填写不完整")
		return false
	}
	
	if(password != passwords){
		alert("两次密码不一致")
		return false
	}
	
	
	return true
}
	
</script>
</head>
<body>
	<div class="page login-page">
		<div class="container d-flex align-items-center">
			<div class="form-holder has-shadow">
				<div class="row">
					<!-- Logo & Information Panel-->
					<div class="col-lg-6">
						<div class="info d-flex align-items-center" style="text-align: center;">
							<div class="content">
								<div class="logo">
									<h1>注册页面</h1>
								</div>
							</div>
						</div>
					</div>
					<!-- Form Panel    -->
					<div class="col-lg-6 bg-white">
						<div class="form d-flex align-items-center">
							<div class="content">
								<form action="registerUser.action" onsubmit="return checkForm()">
									<div class="form-group">
										<input id="register-username" class="input-material"
											type="text" name="registerUsername" placeholder="请输入用户名/姓名">
											<span id="msg"></span>
									</div>
									<div class="form-group">
										<input id="register-password" class="input-material"
											type="password" name="registerPassword" placeholder="请输入密码">
									</div>
									<div class="form-group">
										<input id="register-passwords" class="input-material"
											type="password" name="registerPasswords" placeholder="确认密码">
									</div>
									<div class="form-group">
										<input id="regbtn" type="submit" name="registerSubmit"
											class="btn btn-default btn-info btn-block"
											style="background-color: #5bc0de" value="注册" />
									</div>
									<small>已有账号?</small><a href="${pageContext.request.contextPath}/login.jsp" class="signup">&nbsp;登录</a>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>